#!/bin/sh
#参数1 应用程序名称，如foxit-userspace-web
#参数2 保存包的绝对目录，必须以/s3开头，如：/s3/webreader/webapp/
#参数3 包的版本号,格式为：svn版本_war包版本 （如：24569_V1.0）
#参数4 Tomcat 机器IPS,以逗号分隔
#参数5 应用域名，如userspace.foxitcloud.com

if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] || [ -z "$4" ] || [ -z "$5" ]
then
	echo "Parameters Fail....."
	exit 1;
fi

. /etc/puppet/tool/puppetFun.sh

APP_FILE_NAME=$1

SHELL_FILENAME="${JOB_NAME}_Deploy.sh"
cp -rf /etc/puppet/tool/deployRemoteRun.sh /etc/puppet/files/${SHELL_FILENAME}

packageVersionArray=(`echo ${3//_/ }`)
saveDir="${2}/${packageVersionArray[1]}/${packageVersionArray[0]}/"

Puppet_Run_Whole_Transfer "${4}" "${SHELL_FILENAME}" "" "${SHELL_FILENAME}" "${APP_FILE_NAME}" "${saveDir}" "deployWar.sh" "${APP_FILE_NAME} ${5} ${packageVersionArray[1]}"

retVal=$?
if [ $retVal -eq 0 ]
then
	echo "Deploy Package Success..........."
else
	echo "Deploy Package Fail..........."
fi

exit $retVal